//
//  ZYTimerTest.m
//  OC_Principle
//
//  Created by wangzhipan on 2025/2/18.
//

#import "ZYTimerTest.h"
#import "ZYTimerProxy.h"
#import "ZYProxy1.h"
#import <UIKit/UIKit.h>

@interface ZYTimerTest()
@property (nonatomic, strong, nullable) CADisplayLink *timer;
@end

@implementation ZYTimerTest
- (instancetype)init
{
    if (self = [super init]) {
        [self initTimer];
    }
    return self;
}

- (void)initTimer
{
    ZYProxy1 *proxy = [[ZYProxy1 alloc] initWithTarget:self];
    _timer = [CADisplayLink displayLinkWithTarget:proxy selector:@selector(updateTimer)];
    [_timer addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
}

- (void)updateTimer
{
    NSLog(@"%s", __func__);
}

- (void)dealloc
{
    [self.timer invalidate];
    self.timer = nil;
    
    NSLog(@"%s", __func__);
}
@end
